package com.ruoyi.car.service.carmanage.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.pojo.TbCarOperation;
import com.ruoyi.car.mapper.carmanage.TbCarOperationMapper;
import com.ruoyi.car.service.carmanage.TbCarOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 车辆运营表Service业务层处理
 * 
 * @author 仲晓天
 *
 */
@Service
public class TbCarOperationServiceImpl implements TbCarOperationService {

    @Autowired
    private TbCarOperationMapper tbCarOperationMapper;


    @Override
    public List<TbCarOperation> selectTbCarOperationList(TbCarOperation tbCarOperation) {
        QueryWrapper queryWrapper =  new QueryWrapper<TbCarOperation>();

        //String period = tbCarOperation.getInsurancePeriod();

        queryWrapper.like(tbCarOperation.getCarId() != null,"car_id",tbCarOperation.getCarId());
        queryWrapper.like(tbCarOperation.getOperatorAreaId() != null,"operator_area_id",tbCarOperation.getOperatorAreaId());
        queryWrapper.like(tbCarOperation.getInternalNumber() != null,"internal_number",tbCarOperation.getInternalNumber());
        queryWrapper.like(tbCarOperation.getOperatingUnit() != null,"operating_unit",tbCarOperation.getOperatingUnit());
        queryWrapper.like(tbCarOperation.getCarUsage() != null,"car_usage",tbCarOperation.getCarUsage());
        queryWrapper.like(tbCarOperation.getOperatingDate() != null,"operating_date",tbCarOperation.getOperatingDate());
        queryWrapper.like(tbCarOperation.getDepositArea() != null,"deposit_area",tbCarOperation.getDepositArea());
        queryWrapper.like(tbCarOperation.getResponsibleId() != null,"responsible_id",tbCarOperation.getResponsibleId());
        queryWrapper.like(tbCarOperation.getResponsibleName() != null,"responsible_name",tbCarOperation.getResponsibleName());
        queryWrapper.like(tbCarOperation.getResponsibleTel() != null,"responsible_tel",tbCarOperation.getResponsibleTel());
        queryWrapper.like(tbCarOperation.getAsPeriod() != null,"as_period",tbCarOperation.getAsPeriod());
        queryWrapper.like(tbCarOperation.getInsurancePeriod() != null,"insurance_period",tbCarOperation.getInsurancePeriod());

        return tbCarOperationMapper.selectList(queryWrapper);
    }

    @Override
    public int insertTbCarOperation(TbCarOperation tbCarOperation) {
        return tbCarOperationMapper.insert(tbCarOperation);

    }

    @Override
    public TbCarOperation selectTbCarOperationById(Long id) {
        return tbCarOperationMapper.selectById(id);
    }

    @Override
    public int updateTbCarOperation(TbCarOperation tbCarOperation) {
        return tbCarOperationMapper.updateById(tbCarOperation);
    }

    @Override
    public int deleteTbCarOperationByIds(String ids) {
        return tbCarOperationMapper.deleteById(ids);
    }
}
